import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
    {
      path:"/",
      redirect:"/home"
    },
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/Home.vue'),
    children:[
      {
        path:'/index',
        name:'index',
        component:()=>import('../views/index/Index.vue')
      },
      {
        path:'/user',
        name:'user',
        component:()=>import('../views/user/User.vue')
      },
      {
          path:'/stu',
          name:'stu',
          component:()=>import('../views/stu/Stu.vue')
      },
      {
          path:'/shop',
          name:'shop',
          component:()=>import('../views/shop/Shop.vue')
      }
    ]
   },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
      path: '/register',
      name: 'register',
      component: () => import('../views/Register.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router
